﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using IService;
using Infrastructure;
using Models;
using System.Runtime.Remoting;
using ConcreteService;

namespace TestConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            SetConfig();

            ITaskService service = FactoryCreator.Create<TaskService>();
            TaskInfo task = new TaskInfo();
            task.Name = "Test7";
            task.Remark = "Remark";
            task.StartDate = DateTime.Now;
            task.EndDate = DateTime.Now;
            task.Creator = "xiaoboli";

            service.Create(task);


            

            //ObjectHandle handle = Activator.CreateInstance("ConcreteService", "ConcreteService.TaskService", true, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, null, null, null, null);
            //TaskService obj = (TaskService)handle.Unwrap();
            //TaskInfo info1 = obj.GetTaskInfo("T000000034");

            //TaskInfo info = service.GetTaskInfo("T000000034");
            //info.Name = "Test1";

            //service.UpdateTask(info);

            Console.WriteLine(task.Name);
            Console.ReadLine();
        }

        private static void SetConfig()
        {
            //Read configuration
            string strProvider = ConfigurationManager.AppSettings["DbProvider"];
            string strConn = ConfigurationManager.AppSettings["KdcTicket"];

            DBHelper.CreateSpringDBConn(strConn, strProvider);
            FactoryCreator.Initialize();
        }
    }
}
